package DataConnectionInterface;

import java.util.List;
import Other.*;
import Helper.GameException;

public interface GameDataConnectionInterface {

	/**
	 * Creates (and imports all data for) the database.
	 * @param character_tsv - path to the fictional_character.tsv file
	 * @param universe_tsv - path to the fictional_universe.tsv file
	 * @throws GameException
	 */
	public void CreateDataBase(String character_tsv,
			String universe_tsv) throws GameException;

	/**
	 * Returns numberOfCards from the universe whose name is universeName.
	 * If there are less, repeats some cards randomly.
	 * @param universeName - name of the universe
	 * @param numberOfCards - the number of cards
	 * @return
	 * @throws GameException
	 */
	public List<Card> getCardsFromUniverse(String universeName,
			int numberOfCards) throws GameException;

	/**
	 * Returns the names of all universes with at least num cards
	 * @param num - number of cards
	 * @return
	 * @throws GameException
	 */
	public List<UniverseInformation> getLargeUniverses(int num)
			throws GameException;

	/**
	 * Returns the maxNumberOfHighScores users with highest highscore
	 * @param maxNumberOfHighScores - number of users to return
	 * @return
	 * @throws GameException
	 */
	public List<UserInfo> getHighScores(int maxNumberOfHighScores)
			throws GameException;

	/**
	 * Update user_id's win/loss count based on hasWon
	 * @param user_id - the id of the user
	 * @param hasWon - true <=> the user has won a match
	 * @throws GameException
	 */
	public void updateUserStatistics(int user_id, boolean hasWon)
			throws GameException;

	/**
	 * Returns true <=> the user can enter the system.
	 * He can if he's new or he exists and he gave the right password.
	 * In that case, also updates his last message/description.
	 * The function also sets the user id to his id in this case.  
	 * @param ui - user info
	 * @return
	 * @throws GameException
	 */
	public boolean authenticateUser(UserInfo ui) throws GameException;

	/**
	 * Updates the value of a card
	 * @param card - information with which to update the card
	 * @param cardID - id of the card to update
	 * @throws GameException
	 */
	public void updateCharacter(ServerCard card, int cardID) throws GameException;

	/**
	 * Deletes a character.
	 * @param characterID - the character's id.
	 * @throws GameException
	 */
	public void deleteCharacter(int characterID) throws GameException;

	/**
	 * creates a new (empty) universe
	 * @param universe_name
	 */
	public void addUniverse(String universe_name) throws GameException; 

	/**
	 * deletes a universe
	 * @param universe_id - the id of the universe to delete
	 * @throws GameException
	 */
	public void deleteUniverse(int universe_id) throws GameException;

	/**
	 * removes a character from a universe
	 * @param character_id - the character's id
	 * @param universe_id - the universe's id
	 * @throws GameException
	 */
	public void removeCharacterFromUniverse(int character_id,
			int universe_id) throws GameException;

	/**
	 * insert a new character into a universe
	 * @param card - values for
	 * @param universe_id - the universe's id
	 * @throws GameException
	 */
	public void insertCharacterToUniverse(ServerCard card,
			int universe_id) throws GameException;

	/**
	 * deletes a user 
	 * @param userID - the user's id
	 * @throws GameException
	 */
	public void deleteUser(int userID) throws GameException;

	/**
	 * inserts a new user
	 * @param user - class with information about the new user
	 * @throws GameException
	 */
	public void insertUser(User user) throws GameException;

	/**
	 * Updates an existing user
	 * @param user - info to put into existing user
	 * @param userID - id of existing user
	 * @throws GameException
	 */
	public void updateUser(User user, int userID) throws GameException;

	/**
	 * Returns a page of universes (the universes' names)
	 * @param pageNumber - number of page
	 * @param entriesPerPage - number of entries per page
	 * @return
	 * @throws GameException
	 */
	public List<Universe> getUniversePage(int pageNumber,
			int entriesPerPage) throws GameException;
	
	/**
	 * Returns a page of users
	 * @param pageNumber - number of page
	 * @param entriesPerPage - number of entries per page
	 * @return
	 * @throws GameException
	 */
	public List<User> getUserPage(int pageNumber, int entriesPerPage)
			throws GameException;

	/**
	 * Returns a page of cards
	 * @param pageNumber - number of page
	 * @param entriesPerPage - number of entries per page
	 * @return
	 * @throws GameException
	 */
	public List<ServerCard> getCardPage(int universe_id, int pageNumber, int entriesPerPage)
			throws GameException;


}